<div class="maintop">
	当前位置：编辑商品属性
	<a href="javascript:;" action="<?=$basepath?>" class="mainFrame button">返回</a>
	<a href="javascript:;" action="<?=$basepath?>_edit?id=<?=$datas['id']?>&csid=<?=$datas['categorysubid']?>" class="mainFrame button">刷新</a>
</div>
<div class="main-search">
</div>
<div id="mainbody">
	<div class="main">
		<div class="info">
				<form name="add_save" action="<?=$basepath?>_edit_save" method="POST" target="ajax" func="form_submit">
				<input type="hidden" name="id" value="<?=$datas['id']?>" />
					<dl><dt>名称：</dt><dd><input type="text" name="title" class="wtxt" value="<?=$datas['title'] ?>" /></dd></dl>
					<dl><dt>分类：</dt><dd><select type="text" name="categoryid" id="categoryid">
						<option value="0" <?=(0==intval($datas['categoryid']) ? ' selected="selected"':'') ?>>请选择</option>
						<?php
							if($parent_category){
								foreach($parent_category as $k=>$v){
									echo '<option value="',$k,'"'.($k==intval($datas['categoryid']) ? ' selected="selected"':'').'>',$v,'</option>';	
								}
							}
						?>
						</select></dd>
						<dd><select name="categorysubid" id="categorysubid">
							<option value="0" select="selected">请选择</option>
						</select></dd></dl>
					<dl><dt>默认值：</dt><dd><input type="text" name="defaultvalue" id="defaultvalue" class="wtxt" value="<?=$datas['defaultvalue'] ?>" /></dd><dd class="t">多个默认值用“|”分隔</dd></dl>
					<dl><dt>属性样式：</dt><dd><select name="defaultvaluestyle">
						<? 
						foreach($this->input_type as $k=>$v){ ?>
						<option value="<?=$k?>"<?=(intval($datas['defaultvaluestyle'])==$k ? ' selected="seletced"' : '')?>><?=$v?></option>
						<? $_select = ''; } ?>
					</select></dd></dl>
					<dl><dt>排序：</dt><dd><input type="text" name="sort" class="mint" value="<?=$datas['sort'] ?>" /></dd><dd class="t">按0,1,2,3的顺序排序</dd></dl>
					<dl><dt>快捷搜索：</dt><dd><select name="search">
						<option value="0"<?=(intval($datas['search'])==0 ? ' selected="seletced"' : '')?>>禁用</option>
						<option value="1"<?=(intval($datas['search'])==1 ? ' selected="seletced"' : '')?>>启用</option>
					</select></dd></dl>
					<dl><dt>&nbsp;</dt><dd>
							<input type="submit" value="确认" class="btnbig" />
                            <a href="javascript:;" action="<?=$basepath?>" class="mainFrame btnbig">返回</a>
					</dd></dl>
				</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	$(document).ready(function(){
		var _default_sub_html = '';
		<? 
		$_de_sub = '<option value="0" '.(intval($datas['categorysubid'])==0 ? ' selected="selected"':'').'>请选择</option>';
		 if($categorysub && count($categorysub)){
			foreach($categorysub as $k=>$v){
				$_de_sub .= '<option value="'.$k.'" '.($k==intval($datas['categorysubid']) ? ' selected="selected"':'').'>'.$v.'</option>';
			}
		}
		echo '_default_sub_html = \''.$_de_sub.'\';';									   
		?>
		if(_default_sub_html!==''){
			$('#categorysubid').html(_default_sub_html);
		}else{
			$('#categorysubid').hide();
		}
		$("#categoryid").change(function(){
			var _vid = $(this).val();
			var _subcategory = $("#categorysubid");
			if(parseInt(_vid)>0){
				$('#categorysubid').fadeIn(500);
				jsondata({
					url : '/product/attribute_search_select',
					data : { id : _vid},
					type : 'GET',
					callback : function(data, textStatus, xhr){
						var _html = '<option value="0" selected="selected">请选择</option>';
                		_subcategory.html('');
						$.each(data,function(index,val){
							_html += '<option value="'+val['id']+'">'+val['title']+'</option>';
						});
                		_subcategory.html(_html);
					}
				});
			}else{
				$('#categorysubid').fadeOut(500);
				_subcategory.html('<option value="0" selected="selected">请选择</option>');
			}
		});
	});
</script>
